//
// Created by HZH on 2023-05-01.
//

#ifndef BZDB_BZDB_BZARRAY_T_H
#define BZDB_BZDB_BZARRAY_T_H

#include "../BzDB_type.h"

// 定义一个结构体，.c中都是关于他的操作
typedef struct BzDB_BzArray_t{
    void * buf;
    void * end;

    int buffer_size;
    int max_len;

    int used_count;
}BzDB_BzArray_t;

#ifdef __cplusplus
extern "C"{
#endif

void BzDB_BzArray_init(BzDB_BzArray_t *bzArray , void * buf, int buffer_size  , int buffer_len);
CCBOOL BzDB_BzArray_get(BzDB_BzArray_t *bzArray , int index , void * res);
CCBOOL BzDB_BzArray_insert(BzDB_BzArray_t *bzArray , int index , void * pdata);
CCBOOL BzDB_BzArray_delete(BzDB_BzArray_t *bzArray , int index , void * res);
CCBOOL BzDB_BzArray_update(BzDB_BzArray_t *bzArray , int index , void * res);

CCBOOL BzDB_BzArray_get_last(BzDB_BzArray_t *bzArray  , void * res);
CCBOOL BzDB_BzArray_get_first(BzDB_BzArray_t *bzArray  , void * res);
CCBOOL BzDB_BzArray_delete_last(BzDB_BzArray_t *bzArray  , void * res);
CCBOOL BzDB_BzArray_delete_first(BzDB_BzArray_t *bzArray  , void * res);

void BzDB_BzArray_demo();

#ifdef __cplusplus
}
#endif

#endif //BZDB_BZDB_BZARRAY_T_H
